package cn.slt.controller;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.slt.domian.MD_ObjDSID;
import cn.slt.service.MD_ObjDSIDService;

@Controller
public class MD_ObjDSIDController {
	@Autowired
	private MD_ObjDSIDService service;
	
	@RequestMapping("addobj")
	@ResponseBody
	public String addObj(@RequestParam String sjk,@RequestParam String sjb,@RequestParam String dsname,@RequestParam String beizhu){
		MD_ObjDSID obj=new MD_ObjDSID();
		obj.setBeizhu(beizhu);
		
		System.out.println("1");
		System.out.println(beizhu);
		
		
		
		return"1";
	}

	@RequestMapping("addObjBatch")
	@ResponseBody
	public String addObjBatch(@RequestParam String sjk,@RequestParam String sjb,@RequestParam String dsname,@RequestParam String beizhu){
		return "1";
	}
	
	
	
	@RequestMapping("updateobj_lzd")
	@ResponseBody
	public String updateobj(@RequestParam String sjb,@RequestParam String dsname,@RequestParam String beizhu){
		boolean mark=false;
		String words=null;
		System.out.println(sjb+"sjb");
		dsname=dsname.toUpperCase();
		MD_ObjDSID obj=new MD_ObjDSID();
		obj.setBeizhu(beizhu);
		if (!dsname.equals("")){
			obj.setDsName(dsname.toUpperCase());
		}
		//System.out.println(dsname.length());
		judge(dsname, obj);
		
		System.out.println(beizhu + " : " + dsname);
		
		try{
			mark=service.updateobj(obj);
			System.out.println("yichang1");
			if (mark){
				words = "1";
			} else {
				words ="2";
			}
		}catch(Exception e){
			words="0";
			System.out.println("yichang");
			e.printStackTrace();
		}finally{
			return words;
		}
		
	}

	private void judge(String dsname, MD_ObjDSID obj) {
		
	}
	
	
}
